
export const noop = ()=>{}

//https://blog.csdn.net/hbiao68/article/details/106212919
//https://segmentfault.com/q/1010000008566354
//https://www.v2ex.com/t/688506
export const debounce = (fn: (...args: any[]) => void, interval: number) => {
  let timer: NodeJS.Timeout | null = null

  return function (this:any,...args: any[]){
    const ctx = this
    
    if (timer) {
      clearTimeout(timer)
    }

    timer = setTimeout(() => {
      fn.apply(ctx , args)
    }, interval)
  }
}

